document.querySelectorAll('.tab').forEach(tab => {
    tab.addEventListener('click', () => {
        // 切换标签激活状态
        document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
        tab.classList.add('active');
        
        // 切换表单显示
        const isPasswordLogin = tab.textContent.includes('密码登录');
        document.querySelectorAll('.password-login').forEach(el => el.classList.toggle('active', isPasswordLogin));
        document.querySelectorAll('.sms-login').forEach(el => el.classList.toggle('active', !isPasswordLogin));
        
        // 控制忘记密码链接显示
        document.querySelector('.forgot-password').style.display = isPasswordLogin ? 'block' : 'none';
    });
});

// 验证码倒计时
document.querySelector('.get-captcha').addEventListener('click', function(e) {
        e.preventDefault();
        let countdown = 60;
        const originalText = this.textContent;
        this.disabled = true;       
        const timer = setInterval(() => {
            this.textContent = `重新发送(${countdown})`;
            if(countdown-- <= 0) {
                clearInterval(timer);
                this.textContent = originalText;
                this.disabled = false;
            }
        }, 1000);
    });
